package com.uid.service.impl;

import com.uid.service.IIdService;
import com.uid.util.IdUtil;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  ID服务SnowFlake实现
 * </p>
 *
 * @author Arnold Yang
 * @since 2018-11-16
 */
@Service
public class SnowFlakeIdServiceImpl implements IIdService {

  @Override
  public long nextId() throws Exception {

    try {
      return IdUtil.nextId();
    }catch (Exception e) {
      return nextId();
    }

  }

  @Override
  public long nextId(int stub) throws Exception {
    if(stub == 0){
      return nextId();
    }


    return 0;
  }

}
